package com.east.sng.service.impl;

import com.east.sng.dao.CourseDao;
import com.east.sng.entity.param.CourseParam;
import com.east.sng.entity.result.CourseFind;
import com.east.sng.entity.result.CourseInfo;
import com.east.sng.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author east
 * @date: 2020/12/29
 * @Description:
 **/
@Service
public class CourseServiceImpl implements CourseService {
    @Autowired
    private CourseDao courseDao;

    @Override
    public List<CourseInfo> findCourses(Map<String, Object> params) {
        return this.courseDao.selectCourses(params);
    }

    @Override
    public List<Map<String, String>> findCourseColumns() {
        return this.courseDao.selectCourseColumns();
    }

    @Override
    public CourseFind findCourse(Integer courseId) {
        return this.courseDao.selectCourse(courseId);
    }

    @Override
    public List<Map<String, Object>> findClassrooms(Integer courseTypeId) {
        return this.courseDao.selectClassrooms(courseTypeId);
    }


    @Override
    public void addCourse(CourseParam courseParam) {
        this.courseDao.insertCourse(courseParam);
    }

    @Override
    public void editCourse(CourseParam courseParam) {
        this.courseDao.updateCourse(courseParam);
    }

    @Override
    public boolean removeCourse(Integer courseId) {
        return this.courseDao.deleteOrRecoverCourse(courseId,1)>0;
    }

    @Override
    public boolean batchRemoveCourses(List<Integer> courseIds) {
        return this.courseDao.batchDeleteOrRecoverCourses(courseIds,1)>0;
    }

    @Override
    public boolean recoverCourse(Integer courseId) {
        return this.courseDao.deleteOrRecoverCourse(courseId,0)>0;
    }

    @Override
    public boolean batchRecoverCourses(List<Integer> courseIds) {
        return this.courseDao.batchDeleteOrRecoverCourses(courseIds,0)>0;
    }

}
